#ifndef TEXTUREEDITORDIALOG_H
#define TEXTUREEDITORDIALOG_H

#include <material/materialeditor.h>
#include <material/materialmanager.h>
#include <ui_textureeditorwidget.h>

#include <qgraphicsscene.h>
#include <qgraphicsitem.h>
#include <qgraphicsview.h>


class cceMaterialTextureView : public QGraphicsView
{
  Q_OBJECT
protected:
	void dragEnterEvent(QDragEnterEvent *event);
	void dropEvent(QDropEvent *event);
	void dragMoveEvent(QDragMoveEvent *event);

public:
	cceMaterialTextureView (QWidget* parent = 0);

signals:
  void TextureChanged (const QString& filename);

};


class cceMaterialTextureEditorDialog : public cceMaterialEditorAbstract
{
  Q_OBJECT
private:
  Ui::MaterialTextureEditorWidget   _gui;
  cceMaterialTexture                *_texture;
  cceMaterialTextureView            *_view;
  QGraphicsScene                    *_scene;
  QGraphicsPixmapItem               *_pixmap;
	QString														_filename;


	bool TextureChanged ();
  void UpdateGUIFromTexture ();
	bool UpdateTextureFromGUI ();
protected slots:
	void ForceClose ();
  void SetImage(const QString& image);
	void ChangeTexture (const QString& filename);

	void on_lineEditName_textChanged (const QString&);
	void on_comboBoxTextureGroup_editTextChanged (const QString &);
	void on_comboBoxWrapMode_currentIndexChanged (int);

public:
  cceMaterialTextureEditorDialog(QWidget *parent = 0);
  ~cceMaterialTextureEditorDialog ();

  void SetTexture (cceMaterialTexture* texture);


  QString GetName () const;
  virtual bool Save ();

public slots:
  void Close ();
};

#endif // TEXTUREEDITORDIALOG_H
